package com.example.demo.controller;

import com.example.demo.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Slf4j
@Controller
public class indexController {

    @RequestMapping(value = "/index")
    public String index(){
        log.info("访问主页");
        return "forward:/index.html";
    }


    //访问登录页面
    @RequestMapping(value = "/login")
    public String login(){
        log.info("访问登录页面");
        return "forward:/login.html";
    }
    @Autowired
    LoginService loginService;
    //登录验证
    @RequestMapping(value = "/userlogin")
    public String userlogin(String username,String password){
        log.info("登录验证");
        if (loginService.login(username,password)){
            return "forward:/index.html";
        }else {
            return "forward:/login.html";
        }
        }

    }

